package ${packageName}.api.${moduleName}.control;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import ${packageName}.api.${moduleName}.service.${moduleNameU}Service;

//import ${packageName}.api.${moduleName}.service.model.CreateOrUpdateSpModel;
import com.fosun.spr.core.base.CoBaseControl;
<#list servcieModelList as service>  


import ${packageName}.api.${moduleName}.service.model.${service.methodNameU}SpModel;
import ${packageName}.api.${moduleName}.service.model.${service.methodNameU}SrModel;
</#list>

@RestController
public class ${moduleNameU}Control extends CoBaseControl {
	@Resource
	private ${moduleNameU}Service ${moduleName}Service;

	<#list servcieModelList as service>  
	/**
	 * http://127.0.0.1:8080/${projectWar}/api/${moduleName}/${service.methodName}
	 * http://127.0.0.1:8081/api/${moduleName}/${service.methodName}
	 * <#if service.submitMethod == "POST">{"":"","":""}</#if>
	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/${moduleName}/${service.methodName}",method = RequestMethod.${service.submitMethod})
	public ${service.methodNameU}SrModel ${service.methodName}(HttpServletRequest request,<#if service.submitMethod == "POST">@RequestBody</#if> ${service.methodNameU}SpModel spModel) {
		//SessionUtils.fillSpModel(request, spModel);
		${service.methodNameU}SrModel srModel = ${moduleName}Service.${service.methodName}(spModel);
		return srModel;
	}
	</#list>
	
	
	//生成成json的代码
	public static void main(String[] args) throws Exception{
		<#list servcieModelList as service> 
		<#if service.submitMethod == "POST">
		debugPrintJsonSpModel(new ${service.methodNameU}SpModel());
		</#if>
		</#list>		
	}	
}
